//
//  AbstractScene.m
//  Box2dDemo
//
//  Created by Thi Huynh on 9/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "AbstractScene.h"
#import "Const.h"

@implementation AbstractScene
@synthesize layers =_layers;


- (id)init
{
    self = [super init];
    if(self)
    {
        [self createScene];
    }
    
    return self;
}
 
- (void)createScene
{
    _layers = [[NSMutableArray alloc]init];
}

#pragma mark - add layer section
/****************************************************
/Add layer to scene with no tag, no z
****************************************************/
- (void)addLayer:(CCLayer *)layer
{
    [_layers addObject:layer];
    [self addChild:layer z:_layers.count-1 tag:UNDEFINE_TAG];
}


/***************************************************
/Add layer to scene with  tag, no z
**************************************************/
- (void)addLayer:(CCLayer *)layer withTag:(int)tag
{
    [_layers addObject:layer];
    [self addChild:layer z:_layers.count-1 tag:tag];
}


/***********************************************
/Add layer to scene with no tag, z
**********************************************/
- (void)addLayer:(CCLayer *)layer z:(int)z
{
    [_layers addObject:layer];
    [self addChild:layer z:_layers.count-1 tag:UNDEFINE_TAG];
}


/***********************************************
/Add layer to scene with  tag, z
***********************************************/
- (void)addLayer:(CCLayer *)layer z:(int)z withTag:(int)tag 
{
    [_layers addObject:layer];
    [self addChild:layer z:z tag:tag];
}

#pragma mark - dealloc section
- (void)dealloc
{
    if(_layers)
    {
        [_layers removeAllObjects];
        [_layers release];
        _layers= nil;
    }
    [super dealloc];
}



@end
